﻿Public Partial Class MainPage
    Inherits System.Web.UI.Page

    Dim clsGet As New ClassFunctionGetData
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not (IsPostBack) Then
            Dim div As HtmlControl = CType(Master.FindControl("divForMain"), HtmlControl)
            Dim body As HtmlControl = CType(Master.FindControl("body"), HtmlControl)
            body.Visible = False
            div.Visible = True
        End If
    End Sub

    Private Sub MainPage_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
        Dim ds As DataSet = Session("UserData")
        If Not (ds Is Nothing) Then
            Session("HideMENU") = "H"
            Page.MasterPageFile = clsGet.GetMaster_Page(ds.Tables(0).Rows(0).Item("User_Name").ToString(), "M")
        End If
    End Sub

    Private Sub imgIPORT_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgIPORT.Click
        If (clsGet.CheckExpire()) Then
            ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "myscript", " alert('Connection Expire. Please Contect Admistrator !!');", True)
            Exit Sub
        End If
        Dim ds As DataSet = clsGet.LoadMenu(CType(Session("UserData"), DataSet).Tables(0).Rows(0).Item("Role_no").ToString(), "'Booking','Master','Report','Admin','Operation'")
        If (ds.Tables(0).Rows.Count > 0) Then
            Dim Path As String = ""
            For Each dr As DataRow In ds.Tables(0).Rows
                If (dr.Item("Show_Menu") & "" = "Y") Then
                    Path = dr.Item("Path") & ""
                End If
            Next
            If (Path & "" <> "") Then
                Session("UserMenuRole") = ds
                If (Session("Role") & "" = "00002") Then
                    Response.Redirect("../Form/frm_MyBooking.aspx?P4=B", True)
                Else
                    If (Session("Role") & "" = "00004") Then
                        Response.Redirect("../Form/frm_ManageBooking.aspx?P4=B", True)
                    Else
                        Response.Redirect("../Form/frm_Booking.aspx?P4=B", True)
                    End If

                End If

            Else
                ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "myscript", " alert('คุณไม่มีสิทธิ์ในการใช้งาน เมนู iPORT !!');", True)
            End If

        Else

        End If

    End Sub

    Private Sub imgePayment_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgePayment.Click
        If (clsGet.CheckExpire()) Then
            ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "myscript", " alert('Connection Expire. Please Contect Admistrator !!');", True)
            Exit Sub
        End If
        Dim ds As DataSet = clsGet.LoadMenu(CType(Session("UserData"), DataSet).Tables(0).Rows(0).Item("Role_no").ToString(), "'ePayment'")
        If (ds.Tables(0).Rows.Count > 0) Then
            Dim Path As String = ""
            For Each dr As DataRow In ds.Tables(0).Rows
                If (dr.Item("Show_Menu") & "" = "Y") Then
                    Path = dr.Item("Path") & ""
                End If
            Next
            If (Path & "" <> "") Then
                Session("UserMenuRole") = ds
                Response.Redirect("../Form/" & Path & "" & "?P4=B", True)
            Else
                ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "myscript", " alert('คุณไม่มีสิทธิ์ในการใช้งาน เมนู ePayment !!');", True)
            End If
        Else
            ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "myscript", " alert('คุณไม่มีสิทธิ์ในการใช้งาน เมนู ePayment !!');", True)
        End If
    End Sub

    Private Sub Image1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Image1.Click
        ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "myscript", "window.open('http://www.irpc.co.th');", True)
    End Sub

    Private Sub Image2_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Image2.Click
        ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "myscript", "window.open('http://irpcport-tank.com');", True)
    End Sub

    Private Sub Image3_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Image3.Click
        Dim FileName As String = ""
        Dim FileGen As String = ""
        ' Dim FileType As String = gridfile.DataKeys(Index).Values("File_Type")
        Dim ContentType As String = ""
        If (Session("Role") & "" = "00002") Then
            FileName = "User_Manual_Customer"
            FileGen = "User_Manual_Customer.pdf"   '.pdf
            ContentType = "pdf"  'pdf
        Else
            FileName = "User_Manual"
            FileGen = "User_Manual.pdf"
            ContentType = "pdf"
        End If
        Dim script As String = "window.open('IPORTDownloadfile.aspx?str2=" + FileGen + "&str3=." + ContentType + "&str4=" + FileName + "','_blank','left=0,top=0,location=no,menubar= no,resizable=yes,scrollbars=no,toolbar=no,status=no,width=100px,height=50px');"
        ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "myscript", script, True)
    End Sub
End Class